package dialogos;
import java.awt.BorderLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JFrame;
import javax.swing.JOptionPane;
import javax.swing.SwingUtilities;

import accesoADatos.AccesoADatos;

import datos.Caja;
import datos.Servicio;
import paneles.PanelServ;
import peluqueria.Peluqueria;


/**
* This code was edited or generated using CloudGarden's Jigloo
* SWT/Swing GUI Builder, which is free for non-commercial
* use. If Jigloo is being used commercially (ie, by a corporation,
* company or business for any purpose whatever) then you
* should purchase a license for each developer using Jigloo.
* Please visit www.cloudgarden.com for details.
* Use of Jigloo implies acceptance of these licensing terms.
* A COMMERCIAL LICENSE HAS NOT BEEN PURCHASED FOR
* THIS MACHINE, SO JIGLOO OR THIS CODE CANNOT BE USED
* LEGALLY FOR ANY CORPORATE OR COMMERCIAL PURPOSE.
*/
public class ServDialog extends javax.swing.JDialog {
	private PanelServ panelServ1;

	/**
	* Auto-generated main method to display this JDialog
	*/
	public static void main(String[] args) {
		SwingUtilities.invokeLater(new Runnable() {
			public void run() {
				JFrame frame = new JFrame();
				ServDialog inst = new ServDialog(frame);
				inst.setVisible(true);
			}
		});
	}
	
	public ServDialog(JFrame frame) {
		super(frame);
		initGUI();
	}
	
	private void initGUI() {
		try {
			this.setTitle("Agregar Servicio");
			this.setPreferredSize(new java.awt.Dimension(350, 230));
			BorderLayout thisLayout = new BorderLayout();
			getContentPane().setLayout(thisLayout);
			{
				panelServ1 = new PanelServ();
				getContentPane().add(panelServ1, BorderLayout.CENTER);
				panelServ1.setPreferredSize(new java.awt.Dimension(369, 217));
				panelServ1.getBCancelar().addActionListener(new ActionListener() {
					public void actionPerformed(ActionEvent evt) {
						bCancelarActionPerformed(evt);
					}
				});
				panelServ1.getBAceptar().addActionListener(new ActionListener() {
					public void actionPerformed(ActionEvent evt) {
						bAceptarActionPerformed(evt);
					}
				});
			}
			pack();
			this.setSize(350, 230);
			this.setLocationRelativeTo(null);
			this.setVisible(true);
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
	
	private void bAceptarActionPerformed(ActionEvent evt) {
			Servicio s=(Servicio)this.panelServ1.getServicio();
			AccesoADatos.getInstance().setServicio(s);
			JOptionPane.showMessageDialog(this, "Se ha agregado el serviocio "+s+" a la lista de servicios");
			Peluqueria.getInstance().getpanelServicios().ActualizarServicios();
			this.dispose();
		
	}
	
	private void bCancelarActionPerformed(ActionEvent evt) {
		this.dispose();
	}

}
